<template>

    <div>
        
        关注商品列表:

        <Checkbox :datas="goods" v-model="good_value"  ></Checkbox>

        <br /><br />

        <Button @click="flow" color="green">批量操作</Button>

      </div>
    
</template>

<script>
export default {
    data(){
        return{
            //商品关注列表
            good_value:[],
            goods:[],
            myid:{}

        }
    },
    methods:{
        //批量操作
    flow:function(){


        console.log(this.good_value);

        var goods = [];

        for(let i=0,l=this.good_value.length;i<l;i++){

            goods.push(this.myid[this.good_value[i]]);

        }

        var glist = JSON.stringify(goods);

        console.log(glist);


        this.axios.get('http://localhost:8000/getflow2/',{params:{uid:localStorage.getItem("uid"),ids:glist,type:2}}).then((result) =>{

              console.log(result);

              this.$Message(result.data.message);

      });

    },
    //获取关注商品
    get_goods:function(){

      this.axios.get('http://localhost:8000/uidflow2/',{params:{'uid':localStorage.getItem("uid")}}).then((result) =>{

              console.log(result);

              var goods = [];

              for(let i=0,l=result.data.length;i<l;i++){

                    goods.push(result.data[i].name);
                    this.myid[result.data[i].name] = result.data[i].id;

              }

              //赋值
              this.goods = goods;
              this.good_value = goods;

              console.log(goods);

      });

    }

    }
}
</script>

<style scoped>

</style>